package com.hmall.pojo;

import com.hmall.common.dto.Item;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Data
public class ItemDoc {
    private Long id;//商品id
    private String name;//商品名称
    private Long price;//价格（分）
    private String image;//商品图片
    private String category;//分类名称
    private String brand;//品牌名称
    private Integer sold;//销量
    private Integer commentCount;//评论数
    private Integer isAD;
    private List<String> suggestion=new ArrayList<>();

    public ItemDoc() {
    }

    public ItemDoc(Long id, String name, Long price, String image, String category, String brand, Integer sold, Integer commentCount, Integer isAD, List<String> suggestion) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.image = image;
        this.category = category;
        this.brand = brand;
        this.sold = sold;
        this.commentCount = commentCount;
        this.isAD = isAD;
        this.suggestion = suggestion;
    }

    public ItemDoc (Item item){
        BeanUtils.copyProperties(item,this);
        suggestion.add(item.getBrand());
        suggestion.add(item.getCategory());
    }
}
